﻿namespace HuwmanCode.Samples.WindowsService

open System
open System.ComponentModel
open System.ServiceProcess
open HuwmanCode.ServiceProcess

[<RecoverFromFailures(FailureRecoveryAction.Notify)>] //The recover function in Program.fs should be called.
[<DependsOn(typeof<FSharpWindowsService1>)>]
[<StartAfterInstall>] //This specifies that the service must start immediately after installation
[<Description("FSharp Windows Service 2")>]  //If this is present is will be used for the service description
type FSharpWindowsService2() =
    inherit WindowsServiceBase() //No service name specified, defaulting to the qualified type name

    override x.OnStart(args) =
        //Simulate service failure on startup
        System.Diagnostics.Process.GetCurrentProcess().Kill()
        ()

    override x.OnStop() =
        ()
